package com.example.demozy.service;

import com.example.demozy.client.SinaClient;
import com.example.demozy.client.SinaClientFactory;
import com.example.demozy.config.JuheConfig;
import com.example.demozy.entity.HistoryModel;
import com.example.demozy.entity.Stock;
import com.example.demozy.mapper.StockMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 王成龙
 */
@Service
public class StockService {
    // **************** 公开变量

    // **************** 私有变量

    @Autowired
    private SinaClientFactory sinaClientFactory;

    @Autowired
    private JuheConfig juheConfig;

    @Autowired
    private StockMapper stockMapper;

    // **************** 继承方法

    // **************** 公开方法

    public List<HistoryModel> getStockByCode(String code) {
        SinaClient sinaClient = sinaClientFactory.createClient(juheConfig.getUrl());
        List<HistoryModel> historyModels = sinaClient.queryStock(code);
        return historyModels;
    }

    /**
     * 获取用户所有的条件单回测报告
     *
     * @author 张展鹏
     */
    public List<Stock> listAllStocks(){
        return stockMapper.listAllStocks();
    }

    // **************** 私有方法

}
